// This is an in-place replacement for ServletOutputStream
// http://stackoverflow.com/questions/216894/get-an-outputstream-into-a-string
package by.ad.servlet;

import java.io.IOException;
import javax.servlet.ServletOutputStream;

public class StringOutputStream
  extends ServletOutputStream
{
  @Override
  public void write(int b) 
    throws IOException 
  {
    this.string.append((char) b);
  }

  public String toString() {
    return this.string.toString();
  }
  
  private final StringBuilder string = new StringBuilder(20 * 1024);
}
